<template>
  <div>
    <Table id="table" ref="selection" width="100%"  :columns="listTitle" :data="list" :loading="loading" :height="tableHeight" @on-selection-change="selectItem"></Table>
  </div>
</template>

<script>
  export default {
    props:['listTitle','list','loading'],
    data () {
      return {
        tableHeight:'',
      }
    },
    methods: {
      selectItem (selection) {
        console.log(selection)
        let list = selection;
        let ids = '';
        list.forEach(function(item){
            ids = ids + ',' + item.nid;
        });
        ids = ids.slice(1, ids.length);
        this.$emit('selectItem', ids);
        console.log(ids,'ids');
      }
    },
    mounted() {
      // 设置表格高度
      var height = document.getElementById('table');
      this.tableHeight = window.innerHeight - height.offsetTop - 60;
      window.addEventListener('resize',function(){
        console.log(height.offsetTop)
        if(height.offsetTop!=0){
          this.tableHeight = window.innerHeight - height.offsetTop - 60
        }

      })
    },

  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">

/deep/ .ivu-table-wrapper{
  max-width:1690px;
  // max-height: 520px;
  // overflow: auto;
}
// /deep/ .ivu-table-tip table td {
//     text-align: left;
//     margin-left:200px;
// }
</style>
